//
//  FKGoodsShopAddressCell.m
//  WanTao
//
//  Created by Macbook Pro on 2019/3/18.
//  Copyright © 2019 Macbook Pro. All rights reserved.
//

#import "FKGoodsShopAddressCell.h"
#import "FKCustomBtn.h"

@interface FKGoodsShopAddressCell ()

//@property (nonatomic, weak) UILabel *areaLabel;
@property (nonatomic, weak) UILabel *addressLabel;

@end

@implementation FKGoodsShopAddressCell

- (void)setupSubviews
{
    [super setupSubviews];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
//    UILabel *areaLabel = [UILabel fk_labelWithFont:fk_adjustFont(12) textColor:[UIColor blackColor]];
//    [self.contentView addSubview:areaLabel];
//    self.areaLabel = areaLabel;
    
    UILabel *addressLabel = [UILabel fk_labelWithFont:fk_adjustFont(12) textColor:fkColor666666];
    [self.contentView addSubview:addressLabel];
    self.addressLabel = addressLabel;
    addressLabel.numberOfLines = 4;
    
    FKCustomBtn *addressIconBtn = [FKCustomBtn fk_btnWithTarget:self action:@selector(addressIconBtnClicked) font:fk_adjustFont(11) normalTitle:@"去这里" normalTitleColor:fkMainColor selectedTitle:nil selectedTitleColor:nil normalImg:[UIImage imageNamed:@"go"] selectedImg:nil bgImg:nil selectedBgImg:nil];
    [self.contentView addSubview:addressIconBtn];
    addressIconBtn.imagePosition = FKImagePositionUp;
    addressIconBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
    
    [addressIconBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.offset(fk_adjustW(40));
        make.top.bottom.offset(0);
        make.right.offset(-12);
    }];
    [addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(12);
        make.right.equalTo(addressIconBtn.mas_left).offset(-8);
        make.top.bottom.offset(0);
    }];
//    [areaLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.offset(12);
//        make.top.offset(0);
//    }];
//    [addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(areaLabel);
//        make.right.equalTo(addressIconBtn.mas_left).offset(-8);
//        make.top.equalTo(areaLabel.mas_bottom).offset(fk_adjustW(13));
//    }];
}

- (void)addressIconBtnClicked
{
    if ([self.delegate respondsToSelector:@selector(goodsShopAddressCell:didClickedAddress:)]) {
        [self.delegate goodsShopAddressCell:self didClickedAddress:self.data];
    }
}

- (void)setData:(id)data
{
    [super setData:data];
    
//    self.areaLabel.text = data[@"title"];
    NSMutableAttributedString *attr1 = [fkFORMAT(@"%@\n", data[@"title"]) fk_addAttr:[UIColor blackColor] font:fk_adjustBoldFont(12)];
    NSMutableAttributedString *attr2 = [data[@"address"] fk_addAttr:fkColor666666 font:fk_adjustFont(12)];
    [attr1 appendAttributedString:attr2];
    self.addressLabel.attributedText = attr1;
}

@end
